package com.example.androidsqlitecontactdemo;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;


public class MyHelper extends SQLiteOpenHelper {

    //创建数据库
    public MyHelper(Context context) {
        super(context, "contactdb", null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        //创建数据表
        String sql="create table contacttb(" +
                " _id integer primary key autoincrement," +
                " name varchar(50) not null," +
                " tel varchar(50) not null)";
        db.execSQL(sql);//执行sql语句
        sql = "insert into contacttb(name,tel) values('张三','123456789')";
        db.execSQL(sql);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
